<?php
declare(strict_types=1);

namespace App\Controller\WebApi\Common;

use App\Controller\AbstractController;
use Hyperf\HttpServer\Contract\RequestInterface;
use Hyperf\HttpServer\Annotation\RequestMapping;
use Hyperf\HttpServer\Annotation\Controller;
use App\Middleware\WebApiMiddleware;
use Hyperf\HttpServer\Annotation\Middleware;
use Service\FileService\AliYunOssService;
use Hyperf\Di\Annotation\Inject;

/**
 * 文件服务中心
 * @author chenshubo
 * @Controller(prefix="/webapi/common/upload")
 * @Middleware(WebApiMiddleware::class)
 */
class UploadController extends AbstractController
{
    /**
     * @Inject()
     * @var AliYunOssService
     */
    protected $aliYunOssService;
    
    /**
     * 上传图片资源
     * @RequestMapping(path="uploadSigle", methods="post")
     */
    public function uploadSigle(RequestInterface $request)
    {
        return $this->aliYunOssService->uploadByContents($request->file('file'));
    }
}